<template>
  <div class="work">
    <div class="nav" id="nav">
      <ul>
        <li v-for="(val,ind) in titles" :key="ind" @click="addClass($event,ind)" :class="{current:current==ind}">
          <router-link :to="val.path">
            <span>{{val.title}}</span>
          </router-link>
        </li>
       
      </ul>
    </div>
    <router-view></router-view>
  </div>
</template>
<script>
import {mapState,mapActions} from 'vuex';
export default {
  data() {
    return {
      current:0
    };
  },
   computed: {
    ...mapState(["titles"]),
  },
  methods: {
    addClass(evt,ind) {
      this.current=ind;
    }
  },
  mounted() {
    (this.$parent.title = "作品"), (this.$parent.right = "分类");//改变头部信息
  }
};
</script>
<style scoped>
.work {
  background: #fff;
  width: 100%;
  display: flex;
  flex-direction: column;
  display: relative;
}
.work a {
  text-decoration: none;
  color: #666;
}
.nav {
  flex-shrink: 1;
  width: 100%;
}
.nav ul {
  width: 100%;
  height: 0.8rem;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.nav ul li {
  position: relative;
  border-bottom: none;
  color: #666;
  border-bottom: 2px solid #fff;
}
.nav ul li.current {
  border-bottom: 2px solid #2c72ac;
  color: #2c72ac;
}
.nav ul li.current a {
  color: #2c72ac;
}

</style>
